//////////////////////////////////////////
// Make Table S7
//////////////////////////////////////////


gl path "~/Dropbox/CovidTurnout/replication"

use "$path/original_data/analysis_file_indiana.dta", clear
keep if inlist(age, 64, 65)

// turnout
reg voted age65_2020 is2020 age65_2018 [fw=obs], r
local n1 = e(N)
local ba1 = _b[age65_2020]
local sea1 = _se[age65_2020]
local bi1 = _b[is2020]
local sei1 = _se[is2020]
local ba181 = _b[age65_2018]
local sea181 = _se[age65_2018]
local c1 = _b[_cons]

reghdfe voted age65_2020 age65_2018 [fw=obs], ///
	a(i.c#i.year) vce(robust)
local ba2 = _b[age65_2020]
local sea2 = _se[age65_2020]
local ba182 = _b[age65_2018]
local sea182 = _se[age65_2018]
local n2 = e(N)

	
// absentee
keep if year == 2020

reg absentee age65_2020 [fw=obs], r
local n3 = e(N)
local ba3 = _b[age65_2020]
local sea3 = _se[age65_2020]
local c3 = _b[_cons]
local sec3 = _se[_cons]



reghdfe absentee age65_2020 [fw=obs], ///
	a(i.c#i.year) vce(robust)
local ba4 = _b[age65_2020]
local sea4 = _se[age65_2020]
local n4 = e(N)

// early in person
reg early age65_2020 [fw=obs], r
local n5 = e(N)
local ba5 = _b[age65_2020]
local sea5 = _se[age65_2020]
local c5 = _b[_cons]
local sec5 = _se[_cons]


reghdfe early age65_2020 [fw=obs], ///
	a(i.c#i.year) vce(robust)
local ba6 = _b[age65_2020]
local sea6 = _se[age65_2020]
local n6 = e(N)
	
// election day
reg precinct age65_2020 [fw=obs], r
local n7 = e(N)
local ba7 = _b[age65_2020]
local sea7 = _se[age65_2020]
local c7 = _b[_cons]
local sec7 = _se[_cons]



reghdfe precinct age65_2020 [fw=obs], ///
	a(i.c#i.year) vce(robust)
local ba8 = _b[age65_2020]
local sea8 = _se[age65_2020]
local n8 = e(N)

	
quietly {
	cap log close
	set linesize 255

	log using "$path/output/indiana_table.tex", text replace
	
	noisily dis "\begin{table}[h]"
	noisily dis "\centering"
	noisily dis "\caption{\textbf{Effect of No-Excuse Absentee Voting on Turnout and Vote Mode, Indiana General Elections, 2018 and 2020.} \label{tab:indiana}}"
	noisily dis "\resizebox{1\textwidth}{!}{"
	noisily dis "\begin{tabular}{lcccccccc}"
	noisily dis "\toprule \toprule"
	noisily dis " & \multicolumn{2}{c}{\textbf{Overall Turnout}} & \multicolumn{2}{c}{\textbf{Absentee Voting}} & \multicolumn{2}{c}{\textbf{Early In-Person}} & \multicolumn{2}{c}{\textbf{Elec. Day In-Person}}\\"
	noisily dis " & \multicolumn{2}{c}{Pr(Voted)[0-100\%]} & \multicolumn{2}{c}{Pr(Absentee)[0-100\%]} & \multicolumn{2}{c}{Pr(Early)[0-100\%]} & \multicolumn{2}{c}{Pr(Elec. Day)[0-100\%]} \\[2mm]"
	noisily dis " & (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) \\"
	noisily dis "\midrule"
	noisily dis "No-Excuse (Age=65) $\times$ 2020 & \textbf{" %5.2f `ba1' "} & \textbf{" %5.2f `ba2' "} & \textbf{" %5.2f `ba3' "} & \textbf{" %5.2f `ba4' "} & \textbf{" %5.2f `ba5' "} & \textbf{" %5.2f `ba6' "} & \textbf{" %5.2f `ba7' "} & \textbf{" %5.2f `ba8' "} \\"
	noisily dis " & (" %3.2f `sea1' ") & (" %3.2f `sea2' ") & (" %3.2f `sea3' ") & (" %3.2f `sea4' ") & (" %3.2f `sea5' ") & (" %3.2f `sea6' ") & (" %3.2f `sea7' ") & (" %3.2f `sea8' ") \\[2mm]"
	noisily dis "No-Excuse (Age=65) $\times$ 2018 & " %5.2f `ba181' " & " %5.2f `ba182' "  & " %5.2f `ba183' " & " %5.2f `ba184' " & " %5.2f `ba185' " & " %5.2f `ba186' "  & " %5.2f `ba187' " & " %5.2f `ba188' " \\"
	noisily dis " & (" %3.2f `sea181' ") & (" %3.2f `sea182' ")  &  &  &  &  & &  \\[2mm]"
	noisily dis "2020 & " %5.2f `bi1' " & & " %5.2f `c3' " & & " %5.2f `c5' " & & " %5.2f `c7' " & \\"
	noisily dis " & (" %3.2f `sei1' ") & & (" %3.2f `sec3' ") & & (" %3.2f `sec5' ") & & (" %3.2f `sec7' ") & \\[2mm]"
	noisily dis "Intercept (2018 mean) & " %5.2f `c1' " & & & & & & & \\[2mm]"
	noisily dis " \# Obs & " %12.0fc `n1' " & " %12.0fc `n2' " & " %12.0fc `n3' " & " %12.0fc `n4' " & " %12.0fc `n5' " & " %12.0fc `n6' " & " %12.0fc `n7' " & " %12.0fc `n8' " \\"
	noisily dis " County-by-Year FE & N & Y & N & Y & N & Y & N & Y\\"
	noisily dis "\bottomrule \bottomrule"
	noisily dis "\multicolumn{9}{p{1.25\textwidth}}{\footnotesize Robust standard errors in parentheses. "
	noisily dis "Unit of observation is an individual by year. People in Indiana aged 64 or younger who are eligible to vote"
	noisily dis " must provide a valid excuse if they wish to vote absentee. Those aged 65 or older who are eligible to vote can vote absentee without an excuse.}"
	noisily dis "\end{tabular}}"
	noisily dis "\end{table}"
	
	log off

}

